package stud.mpgame.flash.assets;

import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.PixelSnapping;
import flash.Lib;
import stud.mpgame.flash.map.GameMap;
import stud.mpgame.flash.map.hxjson2.JSON;
import stud.mpgame.flash.map.JsonDataProvider;
import stud.mpgame.flash.map.GameMap;
/**
 * ...
 * @author 
 */

 
 
 class LoadSwfImage {
	 private static var hIm :Float;
	 private static var wIm :Float; 
	 public function new() {
			
		var js:JsonDataProvider = new JsonDataProvider();
		var Fmap:GameMap->Void = function(gmap:GameMap):Void {
			   			
				
		var im = new ImageManager();
		var bitmap = im.getBitmapByID(0);
		hIm = bitmap.height;
		wIm = bitmap.width;
		
		var width = gmap.map.size.width;
		for (i in 0...gmap.map.view.length) {	
		   // trace(gmap.map.view[i]);
			bitmap = im.getBitmapByID(gmap.map.view[i]);		
			bitmap.x = wIm * (i % width);
			bitmap.y = hIm * ((i- (i % width))/width);
			
			Lib.current.addChild(bitmap);
			}
	
		}
		js.provide("http://localhost:8080/maps/map_ex1.json", Fmap);
     }
 }